﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace Fis.Win
{
    public partial class MainForm : DevExpress.XtraEditors.XtraForm
    {
        public void SetMainControl(UserControl control)
        {
            control.DataBindings.Clear();
            control.DataBindings.Add("Size", panelMain, "ClientSize");
            panelMain.Controls.Clear();
            panelMain.Controls.Add(control);
        }

        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            var view = UIManager.ShowEdit<Fis.Service.Forms.LoginForm>("LoginViewProvider");
            if (((DialogResult)view.ViewResult) != DialogResult.OK)
            {
                Application.Exit();
                return;
            }

            Fis.Win.Utils.UIUtils.InitializeNavBarControl(navBarControl);

        }

        private void iPerson_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            UIManager.ShowEdit<Fis.Service.Forms.PersonEditForm>("PersonViewProvider");
        }

        private void iEnterprise_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            UIManager.ShowEdit<Fis.Service.Forms.GroupEditForm>("PersonViewProvider");
        }

        private void iCustom_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            UIManager.ShowList<Fis.Service.Forms.CustomListForm>("CustomListProvider");
        }

        private void iUserAdd_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (Fis.Win.Utils.AppSession.UserInfo["FRIGHTS"].ToString() == "1")
            {
                UIManager.ShowEdit<Fis.Service.Forms.UserEditForm>("UserViewProvider");
            }
            else
            {
                XtraMessageBox.Show("请使用主管身份登录进行操作");
            }

        }

        private void iUserManager_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (Fis.Win.Utils.AppSession.UserInfo["FRIGHTS"].ToString() == "1")
            {
                UIManager.ShowList<Fis.Service.Forms.UserListForm>("UserListProvider");
            }
            else
            {
                XtraMessageBox.Show("请使用主管身份登录进行操作");
            }
            
        }

        private void iBackup_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            UIManager.ShowList<Fis.Service.Forms.BackupForm>("BackupViewProvider");
        }

        private void iVersion_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            UIManager.ShowList<Fis.Service.Forms.VersionForm>("VersionViewProvider");

        }




    }
}